# -*- coding: utf-8 -*-
# @Time    : 2023/5/17 15:22
# @Author  : Pan
# @Software: PyCharm
# @Project : VisualFramework
# @FileName: DDPM_Swin


image_size = (224, 224)
max_steps = int(5e5)

config = {
    "type": "Diffusion",
    "diffusion": {
        "noise_steps": 500,
        "beta_start": 1e-4,
        "beta_end": 0.03,
        "img_size": image_size
    },
    "base_info": {
        "step": max_steps,
        "dot": 100,
        "save_iters": 2000,
        "pretrained": None,
        "save_path": "output/",
        "log_dir": "log_dir/",
    },
    "train_dataset": {
        "type": "DDPMDataset",
        "batch_size": 16,
        "shuffle": True,
        "num_workers": 4,
        "data_root": "cityscapes/Images",
        "transforms": [
            {
                "type": "LoadData",
                "keys": ["img"],
                "func": "cv2"
            },
            {
                "type": "ResizeByShort",
                "keys": ["img"],
                "short": [i for i in range(224, 288, 1)],
                "inter": ["bilinear"]
            },
            {
                "type": "RandPaddingCrop",
                "keys": ["img"],
                "pad_size": image_size,
                "crop_size": image_size
            },
            {
                "type": "ToTensor",
                "keys": ["img"]
            },
            {
                "type": "Normalize",
                "keys": ["img"],
                "mean": 0.5,
                "std": 0.5
            }
        ]
    },
    "eval_dataset": {
        "type": "DDPMDataset",
        "mode": "predict",
        "batch_size": 4,
        "shuffle": True,
        "num_workers": 2,
        "generate_nums": 4,
        "img_size": image_size,
        "transforms": []
    },
    "optimizer": {
        "type": "adam",
        "lr_scheduler": {
            "type": "WarmupCosineLR",
            "learning_rate": 0.0005,
            "total_steps": max_steps,
            "warmup_steps": 10000,
            "warmup_start_lr": 1e-7,
            "end_lr": 1e-7
        },
        "decay": None
    },
    "network": {
        "type": "diffusion",
        "network": {
            "type": "SwinTransformer_base_patch4_window7_224",
            "decoder": {
                "type": "MutilDecoder",
                "embed_dim":  [128, 256, 512, 1024]
            }
        }
    },
    "amp": {
        "scale": 1024
    },
    "loss": {
        "loss_list": [
            {
                "type": "L2Loss"
            }
        ],
        "loss_coef": [1]
    }
}